﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Lidgren.Network;
using WaveEngine.Framework;
using WaveEngine.Components.Graphics2D;
using WaveEngine.Framework.Graphics;
using WaveEngine.Common.Math;


namespace NetworkedGameProject
{
    public enum State
    {
        Idle,
        Left,
        Right
    }

    public class Player
    {
        public float PosX { get; set; }
        //public State AnimState { get; set; }
        public NetConnection Connection { get; set; }
        private Entity Entity;

        public Player(float posX, NetConnection connnection)
        {
            Connection = connnection;
            PosX = posX;
            //AnimState = State.Idle;
        }

        public void Create(string name)
        {
            Entity = new Entity(name)
                            .AddComponent(new Sprite("Content/TimSpriteSheet.wpk"))
                            .AddComponent(new Transform2D()
                                            {
                                                Origin = new Vector2(0.5f, 1.0f),
                                                X = PosX,
                                                Y = 47
                                            })
                            .AddComponent(new SpriteRenderer(DefaultLayers.Alpha));
        }

        public void Update()
        {
            Entity.FindComponent<Transform2D>().X = PosX;
        }

        public void Destroy()
        {
            Entity = null;
        }

        public bool Exist()
        {
            return (Entity != null) ? true : false;
        }
    }
}
